package com.sky.mapper;

import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishFlavorMapper {
    /**
     * 新增口味
     * @param dishFlavor
     */
    @Insert("insert into dish_flavor(dish_id,name,value) values " +
            "(#{dishId},#{name},#{value})")
    void insert(DishFlavor dishFlavor);

    /**
     * 批量插入口味
     * @param list
     */
    void insertBatch(List<DishFlavor> list);

    /**
     * 根据dishI删除对应口味
     * @param dishId
     */
    @Delete("delete from dish_flavor where dish_id=#{dishId}")
    void deleteFlavorByDishId(Long dishId);

    /**
     * 根据dishId批量删除flavor
     * @param dishIds
     */
    void deleteBatchFlavor(List<Long> dishIds);

    /**
     * 根据菜品id获取口味
     * @param dishId
     * @return
     */
    @Select("select * from dish_flavor where dish_id=#{dishId}")
    List<DishFlavor> getFlavorById(Long dishId);
}
